import java.util.Random;

public class TestRandom {
    public static void main(String[] args) {
        String str = GetRandom.getRandom();
        System.out.println(str);
        int sum = GetRandom.sum(str);
        System.out.println(sum);
    }
}

class GetRandom{
    public static String getRandom() {
        int[] num = new int[5];
        int flag = 0;
        StringBuffer str = new StringBuffer();
        while (flag < 5)
        {
            Random random = new Random();
            int tmp = random.nextInt(31) + 20;
            for (int i = 0; i < flag; i++)
            {
                if (tmp == num[i])
                    continue;
            }
            str.append(tmp);
            str.append('-');
            num[flag] = tmp;
            flag++;
        }
        String str1 = new String(str);
        return str1;
    }

    public static int sum(String numStr){
        int sum = 0;
        String[] num = numStr.split("-");
        for(String a: num)
        {
            int number = Integer.parseInt(a);
            sum += number;
        }
        return sum;
    }
}